import AlgoPlus.TORAStockV3x as torastock

if __name__ == '__main__':

    print(f"||Version||,Version:{torastock.getVersion()}")

    subscribe_list1 = ["000001", "600001", "300001"]
    subscribe_list2 = ["000002", "600004", "300002"]

    login_field = torastock.CAPLoginField()
    login_field.UserType = torastock.ENUM_UserType_NSIGHTStock
    login_field.UserID = ""
    login_field.Password = ""
    # NSight股票仿真交易环境（http://n-sight.com.cn）
    login_field.TraderFrontAddress = "tcp://210.14.72.11:4400"
    login_field.MdFrontAddress = "tcp://210.14.72.11:4402"

    trader = torastock.init(1, login_field)

    if trader is not None:
        print("||init||,ErrorID:0,Message:Succeed")

        torastock.subscribe(trader, subscribe_list1)
        for standard_id in subscribe_list2:
            torastock.subscribeOne(trader, standard_id)

        torastock.loop()
    else:
        error_id = torastock.getInitError()
        message = torastock.getMessageByErrorID(error_id)
        print(f"||init||,ErrorID:{error_id},Message:{message}")
